package com.wu.store.dao;

import com.wu.store.entity.Brand;
import com.wu.store.entity.Params;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ParamsDao {
	@Select("<script>" +
		        "select * from t_params " +
		        "<where>" +
		        " status = 1 " +
		        "<if test='keyword != null'>" +
		        " and name like '%${keyword}%'" +
		        "</if>" +
		        "</where>" +
		        " order by create_time desc" +
		        "</script>")
	List<Params> list(String keyword);

	@Insert("insert into t_params (name, create_time) values (#{name}, now())")
	int add(Params params);

	@Update("update t_params set name = #{name}, update_time = now() where id = #{id}")
	int update(Params params);

	@Update("update t_params set status = 0 where id = #{id}")
	int delete(Long id);
}
